Back

Contents

Create a skeleton systemd python daemon

Setup

  1. Create a new (auto-restarting) service definition

         cd  ~/.config/systemd/user
         vi test.service
         [Unit]
         Description=test
    
         [Service]
         ExecStart=/usr/bin/python3 /path/to/service.py
         Restart=on-failure
    
         [Install]
         WantedBy=default.target
  2. Reload systemd services so the new service is picked up

         systemctl --user daemon-reload
  3. Check the service exists

         systemctl --user list-unit-files

To start/stop the service

    systemctl --user start service
    systemctl --user stop service

To enable/disable the service on boot

This service can be persisted on boot by:

    systemctl enable --user service

Top